package cn.drenal.capcap.mapper;

import cn.drenal.capcap.entity.SysRolePermission;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 角色权限关联Mapper接口
 */
@Mapper
public interface SysRolePermissionMapper extends BaseMapper<SysRolePermission> {
    /**
     * 批量插入角色权限关联
     *
     * @param rolePermissions 角色权限关联列表
     */
    /**
     * 批量插入角色权限关联
     *
     * @param rolePermissions 角色权限关联列表
     */
    @Insert("<script>" +
            "INSERT INTO sys_role_permission (id, role_id, permission_id) VALUES " +
            "<foreach collection='rolePermissions' item='item' index='index' separator=','>" +
            "(NULL, #{item.roleId}, #{item.permissionId})" +
            "</foreach>" +
            "</script>")
    void insertBatchSomeColumn(@Param("rolePermissions") List<SysRolePermission> rolePermissions);
}